package com.devmindset.legoframework.usage.client.component;

import java.util.List;

import com.devmindset.legoframework.client.mvc.LegoComponent;
import com.devmindset.legoframework.client.mvc.LegoModel;
import com.devmindset.legoframework.client.mvc.metadata.ComponentStory;
import com.devmindset.legoframework.client.mvc.metadata.Stories;
import com.devmindset.legoframework.usage.client.event.Events;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.calendar.Calendar;
import com.smartgwt.client.widgets.calendar.CalendarEvent;

public class OrganizerComponent extends LegoComponent {
	
	private Calendar calendar;
	
	@Override
	public Canvas construct(LegoModel model) {
		calendar = new Calendar();
		return calendar;
	}
	
	@Override
	public void calculate(LegoModel model) {
		List<CalendarEvent> events = model.getModelData();
		calendar.setData(events.toArray(new CalendarEvent[] {}));
	}

	public ComponentStory myStory() {
		return Stories.component()
			.constructedBy(Events.RENDER_ORGANIZER_COMPONENT)
			.knownAs("Organizer Component");
	}

}